package com.itheima.mapper;

import com.itheima.pojo.OrderSetting;
import com.itheima.pojo.OrderSettingDTO;
import org.apache.ibatis.annotations.*;

import java.util.Date;
import java.util.List;

@Mapper
public interface OrederSettingMapper {
    /**
     * 根据日期修改可预约人数
     * @param orderSettingDTO
     */
    @Update("update t_ordersetting set number = #{number} where orderDate = #{orderDate}")
    void update(OrderSettingDTO orderSettingDTO);

    /**
     * 根据日期获取对应数据
     * @param month
     * @return
     */
    @Select("select * from t_ordersetting where date_format(orderDate,'%Y-%m') = #{month}")
    OrderSetting getByMonth(@Param("month") Date month);

    /**
     * 查询全部数据
     * @return
     */
    @Select("select * from t_ordersetting ")
    List<OrderSetting> list();

    /**
     * 添加数据
     * @param date
     */
    @Insert("insert into t_ordersetting (orderDate, number) values (#{date},#{number})")
    void uploadReservation(@Param("date") Date date,@Param("number") Integer number);
}
